<?php
class ImageComponent extends Object
{
    var $controller = true;
 
    function imageResize($srcFile, $destFile, $maxSize, $quality, $setHeight = false)
    {
		// Set width or height to maxSize depending on if you have setHeight set to TRUE or not, it will also keep the picture aspect ratio the same.
	
		// Get new dimensions
		list($width_orig, $height_orig) = getimagesize($srcFile);

		if ($setHeight == false) {
		   $width = $maxSize;
		   $height = ceil(($maxSize / $width_orig) * $height_orig);
		} else {
		   $width = ceil(($maxSize / $height_orig) * $width_orig);
		   $height = $maxSize;
		}
		
		// Resample
		$image_p = imagecreatetruecolor($width, $height);
		$image = @imagecreatefromgif($srcFile);
		if(@imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig)==false)
		{
			//echo 'sasas';
			return false;
		}

		return imagegif($image_p,$destFile, $quality);
	}
}
?>